require File.expand_path(File.join(File.dirname(__FILE__), 'finder_client'))

class NetiTaxonFinderClient < FinderClient
  def initialize(config_file="neti_config.yml")
    super
    @names = []
  end
  
  def add_name(name)
    @names << name
  end
  
  def get(data)
    data_length = data.length
    socket.write("Content-length: #{data_length}\r\n")
    socket.write(data)
    socket.flush

    response = socket.read(data_length)
    socket.close
    current_pos = 1
    response.each do |name|
      name = name.strip
      current_pos += name.size
      @names.add_name(Name.new(name, current_pos))unless name.blank?
    end    
    @names
  end  

  alias_method :find, :get
end